/********************************************************
 *
 * FILE NAME:   filter.h
 *
 * DESCRIPTION:
 *  Module with generic signal filter
 *
 ********************************************************/

#ifndef FILTER_H
#define FILTER_H

/********************************************************/
/*              Includes                                */
/********************************************************/
#include "../signalprocessing.h"

#include <QDebug>
#include <QObject>

/********************************************************/
/*              Defines                                 */
/********************************************************/

/********************************************************/
/*              Macros                                  */
/********************************************************/

/********************************************************/
/*              Typedefs                                */
/********************************************************/

class Filter : public QObject
{
    Q_OBJECT

    protected:
        class FilterOSignal: public OSignal
        {
            private:
                Filter *contextPtr;

            public:
                /********************************************************
                 * Function Name    :   FilterOSignal
                 *
                 * Description      :   Constructor
                 *
                 * Side effects     :
                 *
                 * Comment          :
                 *
                 * Parameters       :   Filter *contextPtr = pointer to context (filter)
                 *                      size_t historyLength = num of previous samples that would be accessible
                 *
                 * Returns      	:
                 *
                 * Reviewed by      :   draganmarjanovic10@gmail.com, v_duschan@hotmail.com
                 *
                 ********************************************************/
                FilterOSignal(Filter *contextPtr, size_t historyLength): OSignal(historyLength)
                {
                    this->contextPtr = contextPtr;
                }

            protected:
                /********************************************************
                 * Function Name    :   onBurstRequest
                 *
                 * Description      :   Called when new burst of samples requested
                 *
                 * Side effects     :
                 *
                 * Comment          :
                 *
                 * Parameters       :   size_t burstLength = burst length
                 *
                 * Returns      	:   true if burst of samples successfully processed, else false
                 *
                 * Reviewed by      :   draganmarjanovic10@gmail.com, v_duschan@hotmail.com
                 *
                 ********************************************************/
                bool onBurstRequest(size_t burstLength);
        };

        ISignal *input;
        OSignal *output;

        sample_t *a;
        size_t aLength;

        sample_t *b;
        size_t bLength;
        size_t order;

    public:
         Filter(QObject *parent = 0);

        /********************************************************
         * Function Name    :   getInputSignal
         *
         * Description      :   Getter for input signal
         *
         * Side effects     :
         *
         * Comment          :
         *
         * Parameters       :
         *
         * Returns      	:   pointer to the input signal
         *
         * Reviewed by      :   draganmarjanovic10@gmail.com, v_duschan@hotmail.com
         *
         ********************************************************/
        ISignal * getInputSignal();
        Q_INVOKABLE EXPORT_SIGNAL(input, ISignal)


        /********************************************************
         * Function Name    :   getOutputSignal
         *
         * Description      :   Getter for output signal
         *
         * Side effects     :
         *
         * Comment          :
         *
         * Parameters       :
         *
         * Returns      	:   pointer to the output signal
         *
         * Reviewed by      :   draganmarjanovic10@gmail.com, v_duschan@hotmail.com
         *
         ********************************************************/
        OSignal * getOutputSignal();
        Q_INVOKABLE EXPORT_SIGNAL(output, OSignal)

};

/********************************************************/
/*              Functions Declarations                  */
/********************************************************/

/********************************************************/
/*              Variables Declarations (IMPORT)         */
/********************************************************/

#endif /* FILTER_H */
